package proxy.cglib.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @description: ToDo
 * @author: marin
 * @time: 2020/7/6 20:11
 */
public class DynamicProxy implements InvocationHandler {

    private RealSubject realSubject;

    public DynamicProxy(RealSubject realSubject){
        this.realSubject = realSubject;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("动态代理方法执行前");
        Object result = method.invoke(realSubject, args);
        System.out.println("动态方法执行完成之后");
        return result;
    }
}
